<?php
/**
 * Created by Zhy
 * User: Zhy
 * Date: 2019/10/21
 * Time: 10:12
 */

namespace app\admin\controller;


use think\Db;
use think\Request;

class About extends Base
{
    /**
     * 平台用户使用协议
     * @return mixed|\think\response\Json
     */
    public function useAgreement(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_about')->where('about_id', 2)->update(['about_content' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '编辑成功']);
            }else{
                return json(['code' => 100, 'msg' => '编辑失败']);
            }
        }
        $agreement = Db::table('up_about')->where('about_id', 2)->value('about_content');
        $this->assign('agreement', $agreement);
        return $this->fetch('about/useagreement');
    }
}